Repository navigation
build: ship shell completions in deb/rpm/apk packages and the Nix flake - #246
Conversation
GoReleaser generates bash, zsh and fish completions with `witr completion` before the build and nfpm installs them into each distro's standard directories. zsh's directory differs per packager: Debian's zsh only searches vendor-completions, Fedora's and Alpine's search site-functions. The flake installs the same completions with installShellCompletion, skipped when cross-compiling since that needs to run the built binary. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Bash only loads the packaged script through bash-completion and Zsh through compinit, so keep the manual setup as the fallback. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Hi @pranshuparmar, gentle nudge on this one when you have a moment — it's been a couple of weeks since the last look. Both completions PRs (#246 here and #244 for Record & Replay) are green on the full matrix (60+ checks across linux/darian/windows/freebsd/loong64, lint, coverage, security scan). #246 is the smaller of the two (shell completions in deb/rpm/apk + Nix flake) and has no review comments yet, so it may be the easiest to land first — happy to address anything that comes up. Also a small heads-up on #244: since it's a bigger feature, if you'd prefer to review it in stages (e.g. the snapshot format first, then the replay path), I can split the PR or add a design summary to the description to make the review easier. |
pranshuparmar
left a comment
There was a problem hiding this comment.
Thanks @Self-Perfection, this should be a good addition.
|
I am a bit confused. Do you want me to do anything else in this PR? I see that you approved the PR, but have not merged it to any branch yet. |
@Self-Perfection No further actions needed from your side. I'm collecting issues/enhancements for the next milestone and it can be far out so I'm considering to merge this directly to main so that Nix flake users can benefit from this, hence kept it open. Allow me a few more days, will merge. |
Description
witr completionalready generates Bash, Zsh and Fish completions, but none of the packages install them, so packaged installs still need a line in the shell config. This PR ships them:.goreleaser.yml): abeforehook generates the three scripts withgo run ./cmd/witr completion <shell>intocompletions/(gitignored), and nfpm installs them:/usr/share/bash-completion/completions/witr/usr/share/fish/vendor_completions.d/witr.fish/usr/share/zsh/vendor-completions/_witrfor deb,/usr/share/zsh/site-functions/_witrfor rpm and apk. Debian's zsh doesn't searchsite-functions(only/usr/local/share/zsh/site-functions), so one path for all three doesn't work.installShellCompletionwith the output of the built binary. It's skipped when cross-compiling, since the binary can't run on the build machine then. The man page is still installed in that case.bash-completionpackage; Zsh:compinit). The manual setup stays as the fallback. The oldevalline for Zsh needscompinittoo, since cobra's script callscompdef.Why this is useful
How it was tested
goreleaser release --snapshot --clean --skip=publishbuilds all archives and packages.goreleaser check, gofmt,go vet ./...andgo test ./...pass.debian:trixie,fedora:latestandalpine:latestcontainers. Bash, Zsh and Fish completions all come up there: Zsh picks_witrup from the per-distro directory, Fish'scomplete -C "witr --po"returns--port. On Debian sid I also pressed a real Tab in Zsh through a pty, with a control run where_witrwas removed.nix build .#defaultpasses. With the result installed in a nix profile, pressing a real Tab afterwitr --po(driven through a pty) completes--portin Bash, Zsh and Fish. As a control, the same flake without this change gives no completion in any of them. Fish's man-page completion generator was disabled for that test so it couldn't mask the result.Type of change
Checklist
stagingbranch, with a Conventional Commits titlemake lintandmake testpass, and my changes add no new compiler,go vetor lint warnings_linux,_darwin,_freebsd,_windows) (n/a, packaging only)docs/js/engine.js, fixtures regenerated) (n/a)--jsonfields are recorded in the JSON contract golden file (n/a)This change was prepared with the help of an AI assistant (Claude Code). All the testing above was actually run.
🤖 Generated with Claude Code